{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "TFclass1.ipynb",
      "version": "0.3.2",
      "provenance": [],
      "collapsed_sections": [],
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/liwenjian12/Tea-Fruit-Mongo/blob/master/TFclass1.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "metadata": {
        "id": "BUozqUMaFmTl",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 233
        },
        "outputId": "17a24bf3-7c58-4ccb-9920-fe96cd31162f"
      },
      "cell_type": "code",
      "source": [
        "# mnist  \n",
        "# cell 1\n",
        "import tensorflow as tf\n",
        "mnist = tf.keras.datasets.mnist\n",
        "\n",
        "(x_train, y_train),(x_test, y_test) = mnist.load_data()\n",
        "x_train, x_test = x_train / 255.0, x_test / 255.0\n",
        "\n",
        "model = tf.keras.models.Sequential([\n",
        "    tf.keras.layers.Flatten(),\n",
        "    tf.keras.layers.Dense(512, activation=tf.nn.relu),\n",
        "    tf.keras.layers.Dropout(0.2),\n",
        "    tf.keras.layers.Dense(10, activation=tf.nn.softmax)\n",
        "])\n",
        "\n",
        "model.compile(optimizer='adam',\n",
        "              loss='sparse_categorical_crossentropy',\n",
        "              metrics=['accuracy'])\n",
        "model.fit(x_train,y_train,epochs=5)\n",
        "model.evaluate(x_test, y_test)"
      ],
      "execution_count": 11,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Epoch 1/5\n",
            "60000/60000 [==============================] - 15s 250us/step - loss: 0.2005 - acc: 0.9415\n",
            "Epoch 2/5\n",
            "60000/60000 [==============================] - 15s 247us/step - loss: 0.0801 - acc: 0.9754\n",
            "Epoch 3/5\n",
            "60000/60000 [==============================] - 15s 249us/step - loss: 0.0529 - acc: 0.9832\n",
            "Epoch 4/5\n",
            "60000/60000 [==============================] - 15s 257us/step - loss: 0.0381 - acc: 0.9875\n",
            "Epoch 5/5\n",
            "60000/60000 [==============================] - 15s 247us/step - loss: 0.0267 - acc: 0.9914\n",
            "10000/10000 [==============================] - 1s 53us/step\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[0.08070771295251325, 0.977]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 11
        }
      ]
    },
    {
      "metadata": {
        "id": "gyXyFVyyJ96y",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 179
        },
        "outputId": "232f9780-e00c-4cb8-faaf-cd4537c2068e"
      },
      "cell_type": "code",
      "source": [
        "# Fashion MNIST cell 2-5\n",
        "# cell 2 :load Fashion mnist data\n",
        "import keras\n",
        "fashion_mnist = keras.datasets.fashion_mnist\n",
        "(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()\n"
      ],
      "execution_count": 13,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Using TensorFlow backend.\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "Downloading data from http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-labels-idx1-ubyte.gz\n",
            "32768/29515 [=================================] - 0s 4us/step\n",
            "Downloading data from http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz\n",
            "26427392/26421880 [==============================] - 2s 0us/step\n",
            "Downloading data from http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-labels-idx1-ubyte.gz\n",
            "8192/5148 [===============================================] - 0s 0us/step\n",
            "Downloading data from http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-images-idx3-ubyte.gz\n",
            "4423680/4422102 [==============================] - 1s 0us/step\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "DtwcvekwKu7v",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 347
        },
        "outputId": "1b5895af-c7c3-4099-c0e8-6163c965c114"
      },
      "cell_type": "code",
      "source": [
        "# cell3 : process datasets and show some information\n",
        "class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',\n",
        "               'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']\n",
        "import matplotlib.pyplot as plt\n",
        "plt.figure()\n",
        "plt.imshow(train_images[0])\n",
        "plt.colorbar()\n",
        "plt.grid(False)\n",
        "\n",
        "train_images = train_images / 255.0\n",
        "\n",
        "test_images = test_images / 255.0"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAFKCAYAAAAHY8iZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3X9sVfX9x/HX7S/aSy8rrb1lnV8Q\nFbRRIBIwFoTRgkpNnIAi0gFZ0i2YAaMCYUgEXYgDCyGRQVZgwpyd2Y33D9NsJG2AmaFrq9JJgKmt\nOrEilluopbQFSun3D2OjcqCfc7n3XM7l+Uj6B4f3ffdz723vu+/POZ/P8fT29vYKAIAfSIj1AAAA\n1ycKBADAEgUCAGCJAgEAsESBAABYokAAACwlxXoAAHAj8Hg8YT82VqsRKBAA4IBrKRCxEnaB+P3v\nf69Dhw7J4/Fo9erVGj16dCTHBQAwVFZWpoMHD+rixYtauHCh9u/fr6NHjyojI0OSVFJSoilTpqiy\nslKvvPKKEhIS9MQTT2j27NlXzRtWgXjnnXd07NgxBQIBffLJJ1q9erUCgUA4qQDghhCtDqK2tlaN\njY0KBAJqbW3VzJkz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165Sfn993bMuWLSouLlZRUZE2b96s\nYDCo4uLiGI7SHqvnJEnLli1TQUFBjEZ1bWpra9XY2KhAIKDW1lbNnDlT+fn5rn6fJOvndd9997n6\nvXIrx6eYrrQsHNePlJQU7dy5U36/v+9YXV2dpk6dKkkqKChQTU1NrIYXFqvn5Hbjx4/XSy+9JEka\nNGiQurq6XP8+SdbPq6enJ8ajujE5XiCiuSw81j7++GM99dRTmjt3rt5+++1YDydsSUlJSk1N/d6x\nrq6uvqmKrKws171nVs9JkioqKrRgwQI9/fTTOn36dAxGFr7ExER5vV5JUjAY1OTJk13/PknWzysx\nMdHV75VbxXwdRLxcZXvLLbdo8eLFKioqUlNTkxYsWKDq6mpXzv/2J17es0cffVQZGRnKy8vTjh07\ntHXrVq1duzbWw7Jt7969CgaD2rVrlx588MG+425/n777vI4cORIX75XbON5BRHNZeCzl5OTo4Ycf\nlsfj0dChQ3XTTTepubk51sOKGK/Xq3PnzkmSmpub42KqJj8/X3l5eZKkwsJCNTQ0xHhE9h04cEDl\n5eXauXOnfD5f3LxPP3xe8fBeuZHjBSKay8JjqbKyUi+//LIkKRQK6dSpU8rJyYnxqCJnwoQJfe9b\ndXW1Jk2aFOMRXbslS5aoqalJ0jfnWL69As0t2tvbVVZWpu3bt/dd3RMP75PV83L7e+VWMVlJvWnT\nJr333nt9y8LvvPNOp4cQcWfPntWKFSt05swZdXd3a/HixfrpT38a62GF5ciRI3rxxRd1/PhxJSUl\nKScnR5s2bdKqVat0/vx55eb1J2RLAAAAgUlEQVTmav369UpOTo71UI1ZPad58+Zpx44dSktLk9fr\n1fr165WVlRXroRoLBAL6wx/+oOHDh/cd27Bhg5599lnXvk+S9fOaNWuWKioqXPteuRVbbQAALLGS\nGgBgiQIBALBEgQAAWKJAAAAsUSAAAJYoEAAASxQIAIAlCgQAwNL/AyQnLbP5ahHEAAAAAElFTkSu\nQmCC\n",
            "text/plain": [
              "<matplotlib.figure.Figure at 0x7feb48a0dfd0>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "metadata": {
        "id": "UzhzTlKQLrPc",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 215
        },
        "outputId": "cacc547b-5866-435e-98a3-7ad9b9c887a7"
      },
      "cell_type": "code",
      "source": [
        "# cell 4: model and train\n",
        "model = keras.Sequential([\n",
        "    keras.layers.Flatten(input_shape=(28, 28)),\n",
        "    keras.layers.Dense(128, activation=tf.nn.relu),\n",
        "    keras.layers.Dense(10, activation=tf.nn.softmax)\n",
        "])\n",
        "model.compile(optimizer=tf.train.AdamOptimizer(),\n",
        "              loss='sparse_categorical_crossentropy',\n",
        "              metrics=['accuracy'])\n",
        "model.fit(train_images, train_labels, epochs=5)"
      ],
      "execution_count": 15,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Epoch 1/5\n",
            "60000/60000 [==============================] - 4s 72us/step - loss: 12.9331 - acc: 0.1975\n",
            "Epoch 2/5\n",
            "60000/60000 [==============================] - 4s 71us/step - loss: 13.5814 - acc: 0.1574\n",
            "Epoch 3/5\n",
            "60000/60000 [==============================] - 4s 71us/step - loss: 14.5063 - acc: 0.1000\n",
            "Epoch 4/5\n",
            "60000/60000 [==============================] - 4s 71us/step - loss: 14.5063 - acc: 0.1000\n",
            "Epoch 5/5\n",
            "60000/60000 [==============================] - 4s 71us/step - loss: 14.5063 - acc: 0.1000\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<keras.callbacks.History at 0x7feb489a8588>"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 15
        }
      ]
    },
    {
      "metadata": {
        "id": "YbVGInBtMJX4",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 89
        },
        "outputId": "68ccd79e-0a6e-421a-da3c-dc826798919b"
      },
      "cell_type": "code",
      "source": [
        "# cell 5: accuracy and predict\n",
        "test_loss, test_acc = model.evaluate(test_images, test_labels)\n",
        "print('Test loss:', test_loss)\n",
        "print('Test accuracy:', test_acc)\n",
        "\n",
        "predictions = model.predict(test_images)\n",
        "print(predictions[0])"
      ],
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "10000/10000 [==============================] - 0s 31us/step\n",
            "Test loss: 14.506285705566405\n",
            "Test accuracy: 0.1\n",
            "[0. 0. 1. 0. 0. 0. 0. 0. 0. 0.]\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}